package com.kinon.ogt.view.activities;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;

import com.kinon.ogt.R;
import com.kinon.ogt.view.adapter.FragmentAdapter;
import com.kinon.ogt.view.fragments.IntroOneFragment;
import com.kinon.ogt.view.fragments.IntroThreeFragment;
import com.kinon.ogt.view.fragments.IntroTwoFragment;
import com.kinon.ogt.view.widget.NoScrollViewPager;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 佛祖保佑 永无BUG
 *
 * @author WangZhiYao
 * @date 2018/4/28
 */
public class IntroActivity extends AppCompatActivity {

    @BindView(R.id.viewPager)
    NoScrollViewPager mViewPager;

    private FragmentAdapter mAdapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_intro);
        ButterKnife.bind(this);

        initData();
        initView();
    }

    private void initData() {
        List<Fragment> fragments = new ArrayList<>();
        fragments.add(0, new IntroOneFragment());
        fragments.add(1, new IntroTwoFragment());
        fragments.add(2, new IntroThreeFragment());

        mAdapter = new FragmentAdapter(getSupportFragmentManager(), fragments);
    }

    private void initView() {
        mViewPager.setPagingEnabled(true);
        mViewPager.setAdapter(mAdapter);
    }
}
